<?php 
//include_once('config.php');
$subMenuItems = array("MANAGE PROGRAMS","MANAGE DAILY LOGS");


//============================
//BEGIN FIGURE OUT CRUMB TRAIL
//============================
$crumb = $subMenuItems[$subMenu];
//figure out subCrumb

if($subMenu == '0'){//Manage Programs
	if($action == 'listPrograms' || !$action){
	    $action = 'listPrograms';
		$subCrumb = "List Programs";
	}else if($action == 'modifyPrograms'){
		$subCrumb = "Modify Programs";
	}else if($action == 'enterPrograms'){
		$subCrumb = "Enter Programs";
	}else if($action == 'searchPrograms'){
		$subCrumb = "Search Programs";
	}
}


if($subMenu == '1'){//Manage Daily Logs

	if(!$_SESSION['log_timestamp']){
		$_SESSION['log_timestamp'] = mktime();
	}elseif($_GET['stamp']){
		$_SESSION['log_timestamp'] = $_GET['stamp'];
	}elseif($_GET['month']){
		$_SESSION['log_timestamp'] = mktime(0,0,0,$_GET['month'],$_GET['day'],$_GET['year']);
	}
	
	
	findMonday($_SESSION['log_timestamp']);
	$weekStartStamp = $_SESSION['nearestMonday'];
	
	$day =array();
	//Setup time stamp for 7 days, week starts on monday
	for($i=0; $i < 7; $i++){
		$day[$i] = ($weekStartStamp + ($i*86400));
	}

		$subCrumb = date("l, M jS, Y", $_SESSION['log_timestamp']);

}
//============================
//END FIGURE OUT CRUMB TRAIL
//============================ 



//=====================================
//BEGIN HEADER DECO====================
//=====================================
    echo"<table width=\"100%\"  border=\"0\" cellpadding=\"0\" cellspacing=\"0\">
  <tr>
    <td style=\"width:25px; background-image:url(images/subHeaderGradient.gif);background-position:left top;background-repeat: repeat-y;\" ></td>
    <td style=\"background-image:url(images/sysAdmin.gif);background-position:left center;background-repeat: no-repeat;\"  class=\"subHeader\" ><U>$pageTitle</U> :: $crumb :: $subCrumb</td>
    <td align=\"right\" valign=\"middle\" style=\"padding-right:20px; background-color:#000000; background-image:url(images/subHeaderCorner.gif); background-position:right top;background-repeat:no-repeat;\"></td>
  </tr></TABLE>";
//=====================================
//END HEADER DECO======================
//=====================================



//##########################################################################################
//BEGIN CODE FOR MANAGE DAILY PROGRAMS======================================================
//##########################################################################################

if($subMenu == '0'){

$tabWidths = array();
  $tabWidths[0]['left'] = '0';
  $tabWidths[0]['text'] = 'List Programs';
  $tabWidths[0]['action'] = 'listPrograms';
  
  $tabWidths[1]['left'] = '-25';
  $tabWidths[1]['text'] = 'Enter Programs';
  $tabWidths[1]['action'] = 'enterPrograms';

  $tabWidths[2]['left'] = '-45';
  $tabWidths[2]['text'] = 'Modify Programs';
  $tabWidths[2]['action'] = 'modifyPrograms';

  $tabWidths[3]['left'] = '-70';
  $tabWidths[3]['text'] = 'Search Programs';
  $tabWidths[3]['action'] = 'searchPrograms';
  
  
//======================================================================
//ADMIN NAVIGATION  - links get there styles from CSS: #admintopnav #a3
//======================================================================
echo"<TABLE border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\">
	<TR>
		<TD valign=\"bottom\"><ul id=\"admintopnav\">";
		
		for ($i = 0; $i < count($tabWidths); $i++) {
			if($action == $tabWidths[$i]['action']){
				echo "<li ><DIV style=\"left:" .$tabWidths[$i]['left'].";\" class=\"here\">" .$tabWidths[$i]['text']. "</DIV></li>";
			}else{
				echo"<li ><a id=\"a".($i+3)."\" href=\"index.php?ID=1&subMenu=0&action=".$tabWidths[$i]['action']."\" >" .$tabWidths[$i]['text']. "</a></li>";
			}
		}

			echo"</ul>
		</TD>
	</TR>
	<TR><TD><DIV class=\"adminsubnav3\"></DIV></TD></TR>
	</TABLE>";
//======================================================================
//END ADMIN NAVIGATION 
//======================================================================






//======================================================================
//BEGIN LIST PROGAMS 
//======================================================================
if($action == 'listPrograms'){
	include('includes/log/ListPrograms.php');
}
//======================================================================
//END LIST PROGAMS 
//======================================================================




//======================================================================
//BEGIN ENTER PROGAMS 
//======================================================================
if($action == 'enterPrograms'){
	include('includes/log/EnterPrograms.php');
}
//======================================================================
//END ENTER PROGAMS 
//======================================================================




//======================================================================
//BEGIN MODIFY PROGAMS 
//======================================================================
if($action == 'modifyPrograms'){
	include('includes/log/ModifyPrograms.php');
}
//======================================================================
//END MODIFY PROGAMS 
//======================================================================




//======================================================================
//BEGIN SEARCH PROGAMS 
//======================================================================
if($action == 'searchPrograms'){
	include('includes/log/SearchPrograms.php');
}
//======================================================================
//END SEARCH PROGAMS 
//======================================================================







}
//##########################################################################################
//END CODE FOR MANAGE DAILY PROGRAMS========================================================
//##########################################################################################


//################################################################################################################
//################################################################################################################
//################################################################################################################
//################################################################################################################
//################################################################################################################


//##########################################################################################
//BEGIN CODE FOR MERGING PROGRAMS AND UNDERWRITERS==========================================
//##########################################################################################

if($subMenu == '1'){

  $tabWidths = array();
  $tabWidths[0]['left'] = '0';
  $tabWidths[1]['left'] = '-18';
  $tabWidths[2]['left'] = '-45';
  $tabWidths[3]['left'] = '-72';
  $tabWidths[4]['left'] = '-96';
  $tabWidths[5]['left'] = '-120';
  $tabWidths[6]['left'] = '-144';
  
  $displayTime = mktime(0,0,0,date("m",$_SESSION['log_timestamp']),date("d",$_SESSION['log_timestamp']),date("Y",$_SESSION['log_timestamp']));
  
//======================================================================
//ADMIN NAVIGATION  - links get there styles from CSS: #admintopnav #a3
//======================================================================
echo"
<script language=\"JavaScript\">
<!--
function backWeek(){
link = \"index.php?ID=1&subMenu=1&stamp=".($displayTime - (7*86400))."\"; 
self.location=link;
}

function forwardWeek(){
link = \"index.php?ID=1&subMenu=1&stamp=".($displayTime + (7*86400))."\"; 
self.location=link;
}

function jumpDate(){
link = \"index.php?ID=1&subMenu=1&month=\" + document.logJump.startMonth.value + \"&day=\" + document.logJump.startDay.value + \"&year=\" + document.logJump.startYear.value; 
self.location=link;
//alert(link);
}




//-->
</script> ";

echo"<TABLE border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\">
	<TR>
		<TD valign=\"bottom\"><ul id=\"admintopnav\">";
		
		for ($i = 0; $i < count($tabWidths); $i++) {
			if($day[$i] == $displayTime){
				echo "<li ><DIV style=\"left:" .$tabWidths[$i]['left'].";\" class=\"hereProgramLogs\">" .date("D",$day[$i]). "</DIV></li>";
			}else{
				echo"<li ><a id=\"a".($i+8)."\" href=\"index.php?ID=1&subMenu=1&stamp=".$day[$i]."\" >" .date("D",$day[$i]). "</a></li>";
			}
		}
			echo"</ul>
		</TD>
	</TR>
	<TR><form action=\"index.php?ID=1&subMenu=1\" method=\"post\" enctype=\"multipart/form-data\" name=\"logJump\" target=\"_self\">
	<TD><DIV class=\"adminsubnav\" style=\"text-align:left;\">
		&nbsp;<input name=\"lastWeek\" type=\"button\" class=\"inputButton\"  value=\"<<-last week\" onClick=\"backWeek()\"> <input name=\"nextWeek\" type=\"button\" class=\"inputButton\"  value=\"next week->>\" onClick=\"forwardWeek()\">&nbsp; - &nbsp;";
	
						$monthsText = array("January","February","March","April","May","June","July","August","September","October","November","December");
						//Month Drop Down List
						echo("<select name=\"startMonth\" size=\"1\" id=\"setDateMonth\">\n");
						$i = 0;
						$q = 1;
						while($i < 12){
							if($q == date("n", mktime())){
							echo("<option value=\"$q\" selected>$monthsText[$i]</option>\n");
							}else{
							echo("<option value=\"$q\">$monthsText[$i]</option>\n");
							}
						++$i;
						++$q;
						}
						echo("</SELECT>\n\n");
						
						//Day Drop Down List
						echo("<select name=\"startDay\" size=\"1\" >\n");
						$i = 0;
						$q = 1;
						while($i < 31){
							if($q == date("j", mktime())){
							echo("<option value=\"$q\" selected>$q</option>\n");
							}else{
							echo("<option value=\"$q\">$q</option>\n");
							}
						++$i;
						++$q;
						}
						echo("</SELECT>\n\n");
						
						
						//Year Drop Down List $yearToStartRecords
						echo("<select name=\"startYear\" size=\"1\" >\n");
						
						for ($i = $GLOBALS['yearToStartRecords']; $i < date("Y"); $i++) {
						
							if($i == date("Y", mktime())){
							echo("<option value=\"" . $i . "\" selected>" . $i . "</option>\n");
							}else{
							echo("<option value=\"" . $i . "\">" . $i . "</option>\n");
							}
													
						}
						

						$i = 0;
						while($i < 5){
							$futureYears = (date("Y") + $i);
							if($futureYears == date("Y", mktime())){
							echo("<option value=\"" . date("Y", mktime()) . "\" selected>" . date("Y", mktime()) . "</option>\n");
							}else{
							echo("<option value=\"$futureYears\">$futureYears</option>\n");
							}
						++$i;
						}
						echo("</SELECT> <INPUT name=\"Submit\" type=\"button\" class=\"inputButton\"  value=\"Change Date\" onClick=\"jumpDate()\"><!--&nbsp; - &nbsp;<input name=\"addProgram\" type=\"button\" class=\"inputButton\"  value=\"Add Program\">--->\n");	

	
	echo"</DIV></TD></form></TR>
	</TABLE>";
//======================================================================
//END ADMIN NAVIGATION 
//======================================================================





//======================================================================
//BEGIN LIST COMPLETE DAY 
//======================================================================
include('includes/log/view_log.php');
//======================================================================
//END LIST COMPLETE DAY 
//======================================================================






}
//##########################################################################################
//ENDCODE FOR MERGING PROGRAMS AND UNDERWRITERS=============================================
//##########################################################################################

$db->disconnect();//Close Connection to DB
?>